﻿Imports DevExpress.XtraReports.UI

Public Class FormLaporanSiswa
    Inherits PageTemplate

    Private Sub LoadData(ByRef ds As DataSet, ByVal exQuery As String, ByVal objek As String, ByVal exKriteria As String)
        Dim strQuery As String()
        Dim err As String = ""
        Dim dt As New DataTable
        strQuery = New String() {exQuery, objek, "nis", exKriteria}
        If exKriteria = "" Then
            If Utils.executeSP("proc_searchall", strQuery, dt) Then
                ds.Tables.Add(dt)
                ds.Tables(0).TableName = objek
            End If
        Else
            If Utils.executeSP("proc_searchallEqual", strQuery, dt) Then
                ds.Tables.Add(dt)
                ds.Tables(0).TableName = objek
            End If
        End If
    End Sub

    Private Sub SimpleButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton3.Click
        Dim ds As New DataSet
        Dim vnis As String = ""
        If CheckEdit1.Checked Then
            vnis = txtNIS.Text
            If vnis = "" Then
                MsgBox("Silahkan Isi NIS !", MsgBoxStyle.Exclamation)
                Exit Sub
            End If
        Else
            vnis = ""
        End If
        LoadData(ds, "*", RadioGroup1.Properties.Items(RadioGroup1.SelectedIndex).Value, replaceInput(vnis))
        BaseMain.LoadPreviewReports(ds, Me.Name, Me.TitleHead, RadioGroup1.SelectedIndex)
    End Sub

    Private Sub CheckEdit1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckEdit1.CheckedChanged
        txtNIS.Text = ""
        If CheckEdit1.Checked Then
            txtNIS.Enabled = True
            SimpleButton1.Enabled = True
        Else
            txtNIS.Enabled = False
            SimpleButton1.Enabled = False
        End If
    End Sub

    Private Function replaceInput(ByVal teks As String) As String
        teks = teks.Replace("\", "\\")
        teks = teks.Replace("'", "\'")
        Return teks
    End Function

    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
        Dim dlgcari As New DialogCariSiswa
        dlgcari.Text = "Pencarian Data Siswa"                
        If dlgcari.ShowDialog() = DialogResult.OK Then
            If Not dlgcari.VarNIS = String.Empty Then
                txtNIS.Text = dlgcari.VarNIS
            End If
        End If
    End Sub

    Private Sub FormLaporanSiswa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LocalSession.SessForm = ""
    End Sub
End Class
